#pragma once

#include "U7FileDefs.h"

PFLEXFILEHEADER CreateFlexFile();
void DestroyFlexFile( PFLEXFILEHEADER header );
PFLEXFILEHEADER AppendFlexEntity( PFLEXFILEHEADER header, const char* entity, long entitySize );

char* GetFlexArchiveFile( PFLEXFILEHEADER header, const char* targetName, long* fileLength );

inline
PFLEXFILEENTRY GetFlexEntry( PFLEXFILEHEADER header, long index )
{
	assert( index < header->count );
	return ((PFLEXFILEENTRY)(header+1)) + index;
}

inline
char* GetFlexEntity( PFLEXFILEHEADER header, long index )
{
	assert( index < header->count );
	return (char*)header + ((PFLEXFILEENTRY)(header+1))[index].offset;
}

